<template>
  <h1>表单组件</h1>
  <el-form style="width: 600px; margin: 0 auto" label-width="80px">
    <el-form-item label="用户名">
      <el-input  placeholder="请输入用户名" v-model="user.name" clearable></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input show-password placeholder="请输入密码" v-model="user.password"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio-button label="男" value="0"></el-radio-button>
        <el-radio-button label="女" value="1"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select placeholder="请选择居住地" v-model="user.city">
        <el-option label="北京" value="beijing"></el-option>
        <el-option label="南京" value="nanjing"></el-option>
        <el-option label="长沙" value="changsha"></el-option>
        <el-option label="重庆" value="chongqing"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.inAdmin" style="--el-switch-on-color: green;--el-switch-off-color: grey"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="reg">点我提交</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {ref} from "vue";

const user = ref({
  name:'',
  password:'',
  gender:'',
  city:'',
  inAdmin:false
})

const reg =()=>{
  console.log(user.value);
  console.log(user.value.name);
}
</script>

<style scoped>

</style>